//
//  MessageTableViewCell.m
//  sklive
//
//  Created by Macx on 2017/6/29.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "MessageTableViewCell.h"
#import "Message.h"
#import "NSString+Common.h"
#import <Masonry.h>

@implementation MessageTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.headPic.frame = CGRectMake(10, 10, SW(9), SW(9));
    self.headPic.layer.cornerRadius = SW(18);
    self.headPic.layer.masksToBounds = YES;
    
    CGSize nickNameSize = [LZCTools textSizeWithText:@"字数" font:kUHSystemFontWithSize(14)];
    CGSize signSize = [LZCTools textSizeWithText:@"字数" font:kUHSystemFontWithSize(12)];
    
    self.nickName.font = kUHSystemFontWithSize(14);
    self.nickName.frame = CGRectMake(20+SW(9), self.headPic.centerY-nickNameSize.height-2, SW(2), nickNameSize.height);
    
    self.genderImg.hidden = YES;
    self.level.hidden = YES;
    
    self.sign.font = kUHSystemFontWithSize(12);
    self.sign.frame = CGRectMake(20+SW(9), 10+SW(9)-signSize.height, SCREEN_WIDTH/2, signSize.height);
    
    self.num.font = kUHSystemFontWithSize(10);
    self.num.frame = CGRectMake(SCREEN_WIDTH-30, 0, self.headPic.width/5*2, self.headPic.width/5*2);
//    [self.num mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_offset(SCREEN_WIDTH-30);
//        make.centerY.mas_equalTo(self.centerY);
//        make.width.mas_offset([LZCTools textSizeWithText:self.num.text font:self.num.font].width);
//    }];
    self.num.centerY = self.headPic.centerY;
    self.num.layer.cornerRadius = self.num.height/2;
    self.num.layer.masksToBounds = YES;
    
    self.date.font = kUHSystemFontWithSize(12);
    self.date.frame = CGRectMake(SCREEN_WIDTH-SW(2)-10, self.nickName.y, SW(2), signSize.height);
}


- (void)setModel:(Message *)model {
    
    if (_model != model) {
        _model = model;
        
        self.nickName.text = @"系统消息";
        self.sign.text = [model valueForKey:@"title"];
        self.headPic.image = IMAGE(@"icon_info_question");
        
        
//        CGSize nickNameSize = [LZCTools textSizeWithText:self.nickName.text font:kUHSystemFontWithSize(14)];
//        self.nickName.frame = CGRectMake(20+SW(9), 10, nickNameSize.width, nickNameSize.height);
//        self.date.text = [NSString timeWithTimeIntervalString:[model valueForKey:@"create_time"]];
        self.date.text = [NSString timeWithTimeIntervalString:model.create_time];
        
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
